package com.nuanshui.heatedloan.middleware.convert;

import java.util.HashMap;
import java.util.Map;

public class BaseConvertService implements ConverterService {

    protected Map<Integer, Converter> maps = new HashMap<Integer, Converter>();

    @Override
    public void addConverter(Map<Integer, Converter> maps) {
        this.maps=maps;
    }

    @Override
    public void addConverter(Integer nType, Converter converter) {
        this.maps.put(nType,converter);
    }

    @Override
    public Object convert(Integer nType, Object obj, Object params) {
        Converter item = maps.get(nType);
        if (item != null) {
            return item.convert(obj, params);
        }

        return null;
    }
}
